using System;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Way.EntityDB.Attributes;
using System.Diagnostics.CodeAnalysis;

namespace CheckIn.AdminServer.UserInfoDBModels
{
    /// <summary>用户信息</summary>
    [TableConfig]
    [Table("userinfo")]
    [Way.EntityDB.DataItemJsonConverter]
    public partial class UserInfo :Way.EntityDB.DataItem
    {
        System.Nullable<Int64> _id;
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [DisallowNull]
        [Column("id")]
        public virtual System.Nullable<Int64> id
        {
            get
            {
                return _id;
            }
            set
            {
                if ((_id != value))
                {
                    SendPropertyChanging("id",_id,value);
                    _id = value;
                    SendPropertyChanged("id");
                }
            }
        }
        string? _Name;
        /// <summary>名称</summary>
        [MaxLength(100)]
        [Display(Name = "名称")]
        [Column("name")]
        public virtual string? Name
        {
            get
            {
                return _Name;
            }
            set
            {
                if ((_Name != value))
                {
                    SendPropertyChanging("Name",_Name,value);
                    _Name = value;
                    SendPropertyChanged("Name");
                }
            }
        }
        string? _Avator;
        /// <summary>头像</summary>
        [MaxLength(255)]
        [Display(Name = "头像")]
        [Column("avator")]
        public virtual string? Avator
        {
            get
            {
                return _Avator;
            }
            set
            {
                if ((_Avator != value))
                {
                    SendPropertyChanging("Avator",_Avator,value);
                    _Avator = value;
                    SendPropertyChanged("Avator");
                }
            }
        }
        string? _OpenId;
        /// <summary>微信openid</summary>
        [MaxLength(50)]
        [Display(Name = "微信openid")]
        [Column("openid")]
        public virtual string? OpenId
        {
            get
            {
                return _OpenId;
            }
            set
            {
                if ((_OpenId != value))
                {
                    SendPropertyChanging("OpenId",_OpenId,value);
                    _OpenId = value;
                    SendPropertyChanged("OpenId");
                }
            }
        }
        Int32 _FllowCount=0;
        /// <summary>关注人数</summary>
        [DisallowNull]
        [Display(Name = "关注人数")]
        [Column("fllowcount")]
        public virtual Int32 FllowCount
        {
            get
            {
                return _FllowCount;
            }
            set
            {
                if ((_FllowCount != value))
                {
                    SendPropertyChanging("FllowCount",_FllowCount,value);
                    _FllowCount = value;
                    SendPropertyChanged("FllowCount");
                }
            }
        }
        System.Nullable<DateTime> _CreateTime;
        [Column("createtime")]
        public virtual System.Nullable<DateTime> CreateTime
        {
            get
            {
                return _CreateTime;
            }
            set
            {
                if ((_CreateTime != value))
                {
                    SendPropertyChanging("CreateTime",_CreateTime,value);
                    _CreateTime = value;
                    SendPropertyChanged("CreateTime");
                }
            }
        }
        /// <summary>把字段的更新，设置为一个指定的表达式值</summary>
        /// <param>指定的更新表达式，如 m=&gt;m.age == m.age + 1 &amp;&amp; name == name + "aa"，相当于sql语句的 age=age+1,name=name + 'aa'</param>
         public virtual void SetValue(System.Linq.Expressions.Expression<Func<UserInfo, bool>> exp)
        {
            base.SetValue<UserInfo>(exp);
        }
    }
    /// <summary>关注</summary>
    [TableConfig]
    [Table("userfllow")]
    [Way.EntityDB.DataItemJsonConverter]
    public partial class UserFllow :Way.EntityDB.DataItem
    {
        System.Nullable<Int64> _id;
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [DisallowNull]
        [Column("id")]
        public virtual System.Nullable<Int64> id
        {
            get
            {
                return _id;
            }
            set
            {
                if ((_id != value))
                {
                    SendPropertyChanging("id",_id,value);
                    _id = value;
                    SendPropertyChanged("id");
                }
            }
        }
        Int64 _UserId;
        /// <summary>关注人</summary>
        [DisallowNull]
        [Display(Name = "关注人")]
        [Column("userid")]
        public virtual Int64 UserId
        {
            get
            {
                return _UserId;
            }
            set
            {
                if ((_UserId != value))
                {
                    SendPropertyChanging("UserId",_UserId,value);
                    _UserId = value;
                    SendPropertyChanged("UserId");
                }
            }
        }
        Int64 _TargetId;
        /// <summary>被关注人</summary>
        [DisallowNull]
        [Display(Name = "被关注人")]
        [Column("targetid")]
        public virtual Int64 TargetId
        {
            get
            {
                return _TargetId;
            }
            set
            {
                if ((_TargetId != value))
                {
                    SendPropertyChanging("TargetId",_TargetId,value);
                    _TargetId = value;
                    SendPropertyChanged("TargetId");
                }
            }
        }
        DateTime _CreateTime;
        [DisallowNull]
        [Column("createtime")]
        public virtual DateTime CreateTime
        {
            get
            {
                return _CreateTime;
            }
            set
            {
                if ((_CreateTime != value))
                {
                    SendPropertyChanging("CreateTime",_CreateTime,value);
                    _CreateTime = value;
                    SendPropertyChanged("CreateTime");
                }
            }
        }
        /// <summary>把字段的更新，设置为一个指定的表达式值</summary>
        /// <param>指定的更新表达式，如 m=&gt;m.age == m.age + 1 &amp;&amp; name == name + "aa"，相当于sql语句的 age=age+1,name=name + 'aa'</param>
         public virtual void SetValue(System.Linq.Expressions.Expression<Func<UserFllow, bool>> exp)
        {
            base.SetValue<UserFllow>(exp);
        }
    }
}

namespace CheckIn.AdminServer.UserInfoDBModels.DB
{
    public class CheckInUserInfo : Way.EntityDB.DBContext
    {
         public CheckInUserInfo(string connection, Way.EntityDB.DatabaseType dbType , bool upgradeDatabase = true): base(connection, dbType , upgradeDatabase)
        {
            if (!setEvented)
            {
                lock (lockObj)
                {
                    if (!setEvented)
                    {
                        setEvented = true;
                        Way.EntityDB.DBContext.BeforeDelete += Database_BeforeDelete;
                    }
                }
            }
        }
        static object lockObj = new object();
        static bool setEvented = false;
        static void Database_BeforeDelete(object sender, Way.EntityDB.DatabaseModifyEventArg e)
        {
             var db =  sender as CheckInUserInfo;
            if (db == null) return;
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<UserInfo>().HasKey(m => m.id);
            modelBuilder.Entity<UserFllow>().HasKey(m => m.id);
        }
        System.Linq.IQueryable<UserInfo> _UserInfo;
        /// <summary>用户信息</summary>
        public virtual System.Linq.IQueryable<UserInfo> UserInfo
        {
            get
            {
                if (_UserInfo == null)
                {
                    _UserInfo = this.Set<UserInfo>();
                }
                return _UserInfo;
            }
        }
        System.Linq.IQueryable<UserFllow> _UserFllow;
        /// <summary>关注</summary>
        public virtual System.Linq.IQueryable<UserFllow> UserFllow
        {
            get
            {
                if (_UserFllow == null)
                {
                    _UserFllow = this.Set<UserFllow>();
                }
                return _UserFllow;
            }
        }
        protected override string GetDesignString()
        {
            var result = new StringBuilder();
            result.Append("\r\n");
            result.Append("H4sIAAAAAAAAA+1ZTW/TMBj+Lzm3KEmTfuw2tUyKQNtEB0IiPbiJ20akzpY4m6aqB4SQQAiNA9y4gJCYhARIQ5q0A/yZreNn4DhukzTptm5pmzJOtV/br18/ft4Ppz1uCzRN6HArT3p+cx10IbfCbVoObtuwvmNyOe6BtefPUDDs+i02zdDJ8CNguqQj9HMjOd7fhsEI");
            result.Append("V7UhwJDqX9WwYSEuNFezEIYIh6b3VN8WlVshTUMnv4JYyqmcBra91aSvcufvDgcvj09/fxw8+65yZNBTR0ceOtBWUMui0hrAoAkcqNQ8LRKRGPct7Snp8H3SqVqm20WO6h1quJUslSN7Idc0w/q9WaSvOKsuthSk2bBL7CdD2HahpxOgdbKECFrAdDyJ3twigNDFTaNt");
            result.Append("eJOJlMmY+rvI7dZgy0AhmQlRG3eCvg5bwDUxxSmQUqz881GUFGfzHu0yeyxbhzY9Gk9Ha4aj2UbXQABbdsjKqgkch52SqaaiNdIOifsNT0vtcdVCLaNNofMlbAMKPwWyH75mnV1EhDISUebRq44JP+iVXEIy8QKSdQBqT0WyDVMfcT7OnHW4d8EognvJ3KmM8fTs7Zvz");
            result.Append("Lz+iDPUbiRwaXcaIROwWQxzaBbbWAfa0JFI5gefpoil5NLQpIJKQCpFyAWwyPw7b559nzw+isK3u+hvNHzhRltMBTkwdOGEcuF/fSFC0tiFicWoE3waRKZNi10zhk1OiXSG1+KXRYKGHXLhBDTQhjkkXFesKWY915fFYN3j1evDh5OzgOEq8zY6FFhLv0uKddKt4J2Wd");
            result.Append("d5VYsnhxNDg6PD05Gbwfy7RrpmkRJS4rua7Cv4Si7RoVm8olUU/lfEZOwT35VnFPnukjolBIJE78+UBpc+33QyWak5fo/VAozOH9EKpeKuIkT0540l29dEkNt2Qvvgy3OdTLlXEm//n0dQJ2W8BuQ7zM6KVTNMfDWs9T+xAZO9SuoT7FqZqug6EN9fAu1NE9fXRpQMlG");
            result.Append("gPXokq6vNbiscb3zi8HFbOb/m6WwG92Kb166N82K4nSVDp94iyNPafnJ8/+Bk40IOwuvW7yDlGfuIEHxmughwfDs4iuj+JSpNJeN/FfJ6g2NAlNRuPgfCvZUMqb4ypxQ9BE0IR7qWEDZl4Wvff8QrQU+m6k5YLUkpc3qeKqdNamX4XPOLczKpMsgoe4RWDB0Eu87j0cH");
            result.Append("0q/vE4u7dxSEixLdKTKbeU58fh3bBmrHFwTuc/U1kUNNNK3hHcsbrUPMFpaLcpHXm6W8IDZBXiqUxHwZlJp5SSwUAeQlvaXxXP8va/oUsfcfAAA=");
            return result.ToString();
        }
    }
}

/*<design>
H4sIAAAAAAAAA81X3W7bNhh9lYDXiqFfO7Hhi1RaNqFbayDpMKAuBlqiHTU0pZFU2iDwxTAM2E3RXWwPsGHACgzYBnTAgF5sL9Ome4x9FCVFVn7mwU7R+MIkRZ5zfHj4UTlDAZZ4ggVB/TOUxKhvuQYa8fQxiWQYoL5toHt4Dk+Rf0Si45A9EISHbJoiA8WTw9MMHsGK
KGUHksOsA8JPCB9adq9jwscajFIuh5bnOvagWBoPs1TIGSdiMMJCPEl5PJwlYlDpGEaKJ2Gf5zA7AaKBYqJ0hOUR4J+N2dbWGKjHqA/ffn8MfwpYqMZjHB2rb5HmPCKqxQnQqUYpv9Hs7MXzhGnBaji480kaEyoqRPUr9UgnEmNkaGaRzDNKNDt82ALkJR+n0TFYZ2qz
DjIcNRxr8nQq4IoMVn+YK9/RTtfrmvGkt23ZE7ztOj17ewf3Jtuu7XQxMd14Gpkw2z/CbEZi2KKMcJkQoTauwXqG7vNkljBMP8U0b8qoqD8C/zsVv7G1ksrFYmEgaOdUET7UUXGdOhxvv3tx/s2fr//+4fzL30BktZkqQSpQodhPaUwgIFNMBTFQhjlhR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